import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Vector;


public class SocketThreadForNewTab extends Thread {
    String hostName;
    int portNumber;
    Socket connectionToReceiver;
    String TabName;
    String UniqueTabName;
    
    public SocketThreadForNewTab(String hostName, int portNumber, String TabName, String UniqueTabName) {
            this.hostName = hostName;
            this.portNumber = portNumber;
            this.TabName = TabName;
            this.UniqueTabName = UniqueTabName;
    }
    
    public void run() {
            try {
                System.out.println("Adding new tab" + " host is " + hostName + " port number " + portNumber);
            	connectionToReceiver = new Socket(hostName, portNumber);
            	if(connectionToReceiver == null ) return;
                    DataOutputStream dos = new DataOutputStream(connectionToReceiver.getOutputStream());
                    dos.writeInt(4);
                    dos.writeUTF(TabName);
                    dos.writeUTF(UniqueTabName);
                    connectionToReceiver.close();
            } catch (UnknownHostException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
            } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
            }
    }
}
